
#include "../include/tricks.h"

int *prefix_sum(int *s, int len)
{
    int *res = (int *)malloc(sizeof(int) * len);
    if (!res)   return NULL;
    memset(res, 0, sizeof(int) * len);

    int idx;
    res[0] = s[0];
    for (idx = 1; idx < len; idx++)
    {
        res[idx] = res[idx - 1] + s[idx];
    }

    return res;
}
